﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Ec_System.Models.Web;
using Ilongshi.Oversea.DataAccess;

namespace Ec_System.Service.Web
{
    public class ManufacturerService
    {
        /// <summary>
        /// 获取品牌列表---带分页
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ManufacturerDataResponse GetManufacturerListWithPage(ManufacturerDataRequest request)
        {
            var cmd = DataCommandManager.GetDataCommand("GetManufacturerListWithPage");
            cmd.SetParameterValue("@PageIndex", request.PageIndex);
            cmd.SetParameterValue("@PageSize", request.PageSize);

            var model = new ManufacturerDataResponse()
            {
                PageIndex = request.PageIndex,
                PageSize = request.PageSize,
                Result = cmd.ExecuteEntityList<ManufacturerData>(),
                TotalCount = cmd.GetParameterValue<int>("@TotalCount")
            };

            return model;
        }

        /// <summary>
        /// 获取品牌产品
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ShopProductDataResponse GetProductListByMidWithPage(ShopProductDataRequest request)
        {
            var cmd = DataCommandManager.GetDataCommand("GetProductListByMidWithPage");
            cmd.SetParameterValue("@PageIndex", request.PageIndex);
            cmd.SetParameterValue("@PageSize", request.PageSize);
            cmd.SetParameterValue("@ManufacturerID", request.ManufacturerID);

            return new ShopProductDataResponse {
                PageSize = request.PageSize,
                PageIndex = request.PageIndex,
                Result = cmd.ExecuteEntityList<ShopProductData>(),
                TotalCount = cmd.GetParameterValue<int>("@TotalCount")
            };

        }
    }
}
